package logic

import (
	"context"
	"house_srv/house"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CollentAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCollentAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CollentAddLogic {
	return &CollentAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CollentAddLogic) CollentAdd(req *types.CollentAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	add, err := l.svcCtx.HouseRpc.CollentAdd(l.ctx, &house.CollentAddRequest{
		UserId:  req.UserId,
		HouseId: req.HouseId,
		Address: req.Address,
	})

	if err != nil {
		return &types.Response{
			Mes:  err.Error(),
			Code: 500,
			Data: nil,
		}, nil
	}
	return &types.Response{
		Mes:  "房源收藏成功",
		Code: 200,
		Data: add,
	}, nil
}
